#ifndef MYTABLEMODEL_H
#define MYTABLEMODEL_H

#include <QAbstractTableModel>
#include <QObject>
#include <QDateTime>

struct MyModelItem
{
    QString projectName;
    QString stroyName;
    QString taskId;
    QString taskName;
    QString taskStatus;
    QString developName;
    QString developRole;
    QString consumed;
    QString title;
    QDate start;
    QDate end;
};

class MyTableModel : public QAbstractTableModel
{
    Q_OBJECT

public:
    QDate taskGntStartDate;
    QDate taskGntEndDate;
    QList<QString> horHeaderData;
public:
    explicit MyTableModel(QObject *parent = nullptr);

    //自定义导入导出数据的接口
    void setModelData(const QList<MyModelItem> &datas);
    QList<MyModelItem> getModelData() const;
    //自定义插入行数据
    bool insertModelData(int row,const MyModelItem &datas);

    //初始化表头数据
    bool setHorHeaderData(const QList<QString> &headers);
    //获取表头数据
    QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
    //设置表头数据
    bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role = Qt::EditRole) override;

    //获取行数
    int rowCount(const QModelIndex &parent = QModelIndex()) const override;
    //获取列数
    int columnCount(const QModelIndex &parent = QModelIndex()) const override;
    //获取单元格数据
    QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
    //设置单元格数据
    bool setData(const QModelIndex &index, const QVariant &value,int role = Qt::EditRole) override;
    //单元格的可操作性标志位，如可编辑，可选中等
    Qt::ItemFlags flags(const QModelIndex& index) const override;

    //添加行列
    bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
    //bool insertColumns(int column, int count, const QModelIndex &parent = QModelIndex()) override;

    //移除行列
    bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
    //bool removeColumns(int column, int count, const QModelIndex &parent = QModelIndex()) override;


private:
    //数据
    QList<MyModelItem> modelData;
};

#endif // MYTABLEMODEL_H
